﻿
<!--
https://github.com/netnr
https://gitee.com/netnr
https://www.netnr.com
https://zme.ink
-->


<!DOCTYPE html>
<html>
<head>

    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <link rel='shortcut icon' href='/favicon.ico' type='image/x-icon' />


    <title>Office文档查看 脚本服务</title>

    <meta name="keywords" content="netnr NET牛人 Office文档查看" />
    <meta name="description" content="Script Services Word、Excel、PPT" />

</head>
<body>
<div id='LoadingMask' style='position:fixed;top:0;left:0;bottom:0;right:0;background-color:white;z-index:19999;background-image:url('/images/loading.svg');background-repeat:no-repeat;background-position:48% 45%'></div>
<link href='https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css' rel='stylesheet'>
<link href='https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css' rel='stylesheet'>
<script src='https://cdn.jsdelivr.net/npm/jquery@3.5.0/dist/jquery.min.js'></script>
<script src='https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.bundle.min.js'></script>
<script src='https://cdn.jsdelivr.net/npm/jzjs@2.0.2/2.0.2/jz.min.js'></script>
<link href='https://cdn.jsdelivr.net/npm/netnrnav@1.1.0/src/netnrnav.css' rel='stylesheet' />
<script src='https://cdn.jsdelivr.net/npm/netnrnav@1.1.0/src/netnrnav.js' defer async></script>

<script>
    $.ajax({
        url: '/images/icon.svg?20201228',
        dataType: 'text',
        success: function (data) {
            $('body').append('<div class="d-none">' + data + '</div>')
        }
    })
</script>

        <link href="/css/global.css?v=YuzFOH_Z7ma5bs-3HMdZQu0aPQZ1pkBqrzQ_Ri8Yh3k" rel="stylesheet" />
        <script src="/js/global.js?v=ckkNo3hER74SKnNCuouMgEfxEpEMP3phtPl9uA0_Lnc"></script>
            <!--导航-->
            <button type="button" class="MenuToggle show-in-mobile btn btn-primary ml-3 mt-3">
                <span class="fa fa-align-justify fa-2x"></span>
            </button>
            <div class="netnrnav horizontal">
                <div class="netnrnav-wrapper">
                    <ul>
                        <li><a href="https://www.netnr.com" class="siteIcon"><img src="/favicon.svg" /> 首页</a></li>
                        <li><a href="https://www.netnr.com/gist/discover" title="代码片段"><span class="fa fa-fw fa-file-code-o"></span> Gist</a></li>
                        <li><a href="https://www.netnr.com/run/discover" title="在线运行代码"><span class="fa fa-fw fa-play"></span> Run</a></li>
                        <li><a href="https://www.netnr.com/doc" title="文档管理"><span class="fa fa-fw fa-book"></span> Doc</a></li>
                        <li><a href="https://www.netnr.com/draw/discover" title="绘制"><span class="fa fa-fw fa-paint-brush"></span> Draw</a></li>
                        <li><a href="/" title="ss.js.org"><span class="fa fa-fw fa-wrench"></span> 服务</a></li>
                        <li style="background-image: radial-gradient(ellipse, white, rgb(227, 248, 240))">
                            <!--标题-->
                                <a href='javascript:location.reload(false)' title="Word、Excel、PPT">
                                    <svg class="titleicon"><use xlink:href="#office"></use></svg> Office&#x6587;&#x6863;&#x67E5;&#x770B;
                                </a>
                        </li>
                        <li>
                            <a class="text-muted"><span class="fa fa-fw fa-ellipsis-h"></span></a>
                            <ul>
                                <li><a target="_blank" title="码云" href="https://gitee.com/netnr"><i class="fa fa-fw fa-git"></i> Gitee <sup><i class="fa small fa-external-link"></i></sup></a></li>
                                <li><a target="_blank" title="GitHub" href="https://github.com/netnr"><i class="fa fa-fw fa-github"></i> GitHub <sup><i class="fa small fa-external-link"></i></sup></a></li>
                            </ul>
                        </li>
                    </ul>
                </div>
            </div>
        <div class="min300 mt-3">
            <div class="container-fluid">
    <div class="row">
        <div class="col-md-12">
            <div class="input-group">
                <span class="input-group-append">
                    <span class="input-group-text">粘贴公网链接</span>
                </span>
                <input id="txtUrl" type="text" class="form-control" placeholder="请粘贴公网文档链接地址">
                <span class="input-group-append">
                    <span class="input-group-text">上传Office文档（Max 20MB）</span>
                </span>
                <div class="custom-file">
                    <input id="txtFile" type="file" class="custom-file-input">
                    <label class="custom-file-label" id="ps">选择本地 Word、Excel、PPT</label>
                </div>
            </div>
            <p>
                <label>全屏完整链接：</label>
                <a target="_blank" id="auri" href="javascript:void(0)">https://view.officeapps.live.com/op/embed.aspx?src=</a>
            </p>
        </div>
        <div class="col-md-12">
            <iframe src="about:blank" frameborder="0"></iframe>
        </div>
    </div>
</div>

<script>
    var ov = {
        api: "https://view.officeapps.live.com/op/embed.aspx?src=",
        view: function (url) {
            if (url && url != "") {
                url = decodeURIComponent(url);
                $('#auri').attr('href', ov.api + url);
                $('#auri').html(ov.api + url);
                $('iframe').attr('src', ov.api + url);
            } else {
                $('#auri').attr('href', 'javascript:void(0);');
                $('#auri').html(ov.api);
                $('iframe').attr('src', 'about:blank');
            }
        },
        size: function () {
            var h = $(window).height() - $('iframe').offset().top - 15;
            $('iframe').height(Math.max(200, h)).width('100%');
        }
    }

    $('#txtUrl').on('input', function () {
        ov.view(this.value);
    });
    $('#txtFile').change(function () {
        var file = this.files[0];
        if (file) {
            var err = [];
            if (file.size > 1024 * 1024 * 20) {
                err.push('文档大小限制 20MB')
            }
            if (file.type.indexOf('application') == -1 || ".doc docx .xls xlsx .ppt pptx".indexOf(file.name.slice(-4).toLowerCase()) == -1) {
                err.push('请选择 Office文档')
            }
            if (err.length) {
                jz.alert(err.join('<br/>'))
            } else {
                //上传
                var formData = new FormData();
                formData.append("file", file);

                $('#ps').html('正在准备上传 ');
                $.ajax({
                    url: "https://ftp.netnr.eu.org/API/UploadTmp",
                    type: "POST",
                    data: formData,
                    contentType: false,
                    processData: false,
                    dataType: 'json',
                    xhr: function () {
                        xhr = $.ajaxSettings.xhr();
                        xhr.upload.addEventListener('progress', function (e) {
                            var rate = ((e.loaded / e.total) * 100).toFixed();
                            if (rate < 100) {
                                $('#ps').html('已上传 ' + rate + ' %');
                            } else {
                                $('#ps').html('选择本地 Word、Excel、PPT');
                            }
                        })
                        return xhr;
                    },
                    success: function (data) {
                        console.log(data);
                        if (data.code == 200) {
                            ov.view("https://ftp.netnr.eu.org" + data.data);
                        } else {
                            jz.alert(data.msg)
                        }
                    },
                    error: function () {
                        jz.alert("上传出错");
                    },
                    complete: function () {
                        $('#txtFile').val('')
                        $('#ps').html('选择本地 Word、Excel、PPT');
                    }
                });
            }
        }
    });

    $(window).on('load resize', function () {
        ov.size();
    });
</script>
        </div>
        <a href="javascript:ss.toTop();" class="totop" title="返回顶部">ˆ</a>
</body>
</html>
